home *** CD-ROM | disk | FTP | other *** search
Wrap
RRRRWWWWCCCCoooolllllllleeeeccccttttiiiioooonnnn((((3333CCCC++++++++)))) RRRRWWWWCCCCoooolllllllleeeeccccttttiiiioooonnnn((((3333CCCC++++++++)))) NNNNaaaammmmeeee RWCollection - Rogue Wave library class SSSSyyyynnnnooooppppssssiiiissss #include <rw/colclass.h> typedef RWCollection Collection; // Smalltalk typedef DDDDeeeessssccccrrrriiiippppttttiiiioooonnnn Class RRRRWWWWCCCCoooolllllllleeeeccccttttiiiioooonnnn is an abstract base class for the Smalltalk-like collection classes. The class contains virtual functions for inserting and retrieving pointers to RRRRWWWWCCCCoooolllllllleeeeccccttttaaaabbbblllleeee objects into the collection classes. Virtual functions are also provided for storing and reading the collections to files and streams. Collections that inherit this base class will typically redefine one or more of these functions. In the documentation below, pure virtual functions are indicated by "= 0" in their declaration. These functions mmmmuuuusssstttt bbbbeeee defined in derived classes. For these functions the description is intended to be generic -- all inheriting collection classes generally follow the described pattern. Exceptions are noted in the documentation for the particular class. For many other functions, a suitable definition is provided by RRRRWWWWCCCCoooolllllllleeeeccccttttiiiioooonnnn and a deriving class may not need to redefine the function. Examples are ccccoooonnnnttttaaaaiiiinnnnssss(((()))) or rrrreeeessssttttoooorrrreeeeGGGGuuuuttttssss(((()))). PPPPeeeerrrrssssiiiisssstttteeeennnncccceeee Polymorphic PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrr OOOOppppeeeerrrraaaattttoooorrrrssss void ooooppppeeeerrrraaaattttoooorrrr++++====(const RWCollection&); void ooooppppeeeerrrraaaattttoooorrrr----====(const RWCollection&); Adds or removes, respectively, each item in the argument to or from self. Using ooooppppeeeerrrraaaattttoooorrrr++++====((((ssssoooommmmeeeePPPPrrrreeeeSSSSoooorrrrtttteeeeddddCCCCoooolllllllleeeeccccttttiiiioooonnnn)))) on an RRRRWWWWBBBBiiiinnnnaaaarrrryyyyTTTTrrrreeeeeeee can cause that tree to become unbalanced; possibly to the point of stack overflow. PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrr FFFFuuuunnnnccccttttiiiioooonnnnssss virtual ~~~~RRRRWWWWCCCCoooolllllllleeeeccccttttiiiioooonnnn(); Null definition (does nothing). PPPPaaaaggggeeee 1111 RRRRWWWWCCCCoooolllllllleeeeccccttttiiiioooonnnn((((3333CCCC++++++++)))) RRRRWWWWCCCCoooolllllllleeeeccccttttiiiioooonnnn((((3333CCCC++++++++)))) virtual void aaaappppppppllllyyyy(RWapplyCollectable ap, void*) = 0; This function applies the user-supplied function pointed to by aaaapppp to each member of the collection. This function should have prototype void yyyyoooouuuurrrrAAAAppppppppllllyyyyFFFFuuuunnnnccccttttiiiioooonnnn(RWCollectable* ctp, void*); The function yyyyoooouuuurrrrAAAAppppppppllllyyyyFFFFuuuunnnnccccttttiiiioooonnnn(((()))) can perform any operation on the item at address ccccttttpppp that ddddooooeeeessss nnnnooootttt cccchhhhaaaannnnggggeeee the hash value or sorting order of the item. Client data may be passed to this function through the second argument. RWBag aaaassssBBBBaaaagggg() const; RWSet aaaassssSSSSeeeetttt() const; RWOrdered aaaassssOOOOrrrrddddeeeerrrreeeeddddCCCCoooolllllllleeeeccccttttiiiioooonnnn() const; RWBinaryTree aaaassssSSSSoooorrrrtttteeeeddddCCCCoooolllllllleeeeccccttttiiiioooonnnn() const; Allows any collection to be converted to an RRRRWWWWBBBBaaaagggg, RRRRWWWWSSSSeeeetttt, RRRRWWWWOOOOrrrrddddeeeerrrreeeedddd, or an RRRRWWWWBBBBiiiinnnnaaaarrrryyyyTTTTrrrreeeeeeee. Note that the return value is a ccccooooppppyyyy of the data. This can be very expensive for large collections. You should consider using ooooppppeeeerrrraaaattttoooorrrr++++====(((()))) to insert each item from this collection into a collection of your choice. Also note that converting a collection containing data which is already sorted to a RRRRWWWWBBBBiiiinnnnaaaarrrryyyyTTTTrrrreeeeeeee via the aaaassssSSSSoooorrrrtttteeeeddddCCCCoooolllllllleeeeccccttttiiiioooonnnn(((()))) or aaaassssBBBBiiiinnnnaaaarrrryyyyTTTTrrrreeeeeeee(((()))) methods will build a very unbalanced tree. virtual RWspace bbbbiiiinnnnaaaarrrryyyySSSSttttoooorrrreeeeSSSSiiiizzzzeeee() const; Redefined from class RRRRWWWWCCCCoooolllllllleeeeccccttttaaaabbbblllleeee. virtual void cccclllleeeeaaaarrrr() = 0; Removes all objects from the collection. Does not delete the objects themselves. virtual void cccclllleeeeaaaarrrrAAAAnnnnddddDDDDeeeessssttttrrrrooooyyyy(); PPPPaaaaggggeeee 2222 RRRRWWWWCCCCoooolllllllleeeeccccttttiiiioooonnnn((((3333CCCC++++++++)))) RRRRWWWWCCCCoooolllllllleeeeccccttttiiiioooonnnn((((3333CCCC++++++++)))) Removes all objects from the collection aaaannnndddd ddddeeeelllleeeetttteeeessss them. Takes into account duplicate objects within a collection and only deletes them once. However, it does nnnnooootttt take into account objects shared between different collections. Either do not use this function if you will be sharing objects between separate collections, or put all collections that could be sharing objects into one single "super-collection" and call cccclllleeeeaaaarrrrAAAAnnnnddddDDDDeeeessssttttrrrrooooyyyy(((()))) on that. virtual int ccccoooommmmppppaaaarrrreeeeTTTToooo(const RWCollectable* a) const; Inherited from class RRRRWWWWCCCCoooolllllllleeeeccccttttaaaabbbblllleeee. virtual RWBoolean ccccoooonnnnttttaaaaiiiinnnnssss(const RWCollectable* target) const; Returns TTTTRRRRUUUUEEEE if the collection contains an item where the virtual function ffffiiiinnnndddd(((()))) returns non-nil. virtual size_t eeeennnnttttrrrriiiieeeessss() const = 0; Returns the total number of items in the collection. virtual RWCollectable* ffffiiiinnnndddd(const RWCollectable* target) const = 0; Returns a pointer to the first item in the collection which "matches" the object pointed to by ttttaaaarrrrggggeeeetttt or nnnniiiillll if no item was found. For most collections, an item "matches" the target if either iiiissssEEEEqqqquuuuaaaallll(((()))) or ccccoooommmmppppaaaarrrreeeeTTTToooo(((()))) find equivalence, whichever is appropriate for the actual collection type. However, the "identity collections" (iiii....eeee...., RRRRWWWWIIIIddddeeeennnnttttiiiittttyyyySSSSeeeetttt and RRRRWWWWIIIIddddeeeennnnttttiiiittttyyyyDDDDiiiiccccttttiiiioooonnnnaaaarrrryyyy) look for an item with the same address (iiii....eeee...., "is identical to"). virtual unsigned hhhhaaaasssshhhh() const; Inherited from class RRRRWWWWCCCCoooolllllllleeeeccccttttaaaabbbblllleeee. virtual RWCollectable* iiiinnnnsssseeeerrrrtttt(RWCollectable* e) = 0; Adds an item to the collection and returns a pointer to it. If the item is already in the collection, some collections derived from RRRRWWWWCCCCoooolllllllleeeeccccttttiiiioooonnnn return the old instance, others return nnnniiiillll. PPPPaaaaggggeeee 3333 RRRRWWWWCCCCoooolllllllleeeeccccttttiiiioooonnnn((((3333CCCC++++++++)))) RRRRWWWWCCCCoooolllllllleeeeccccttttiiiioooonnnn((((3333CCCC++++++++)))) virtual RWClassID iiiissssAAAA() const; Redefined from class RRRRWWWWCCCCoooolllllllleeeeccccttttaaaabbbblllleeee to return ________RRRRWWWWCCCCOOOOLLLLLLLLEEEECCCCTTTTIIIIOOOONNNN. virtual RWBoolean iiiissssEEEEmmmmppppttttyyyy() const = 0; Returns TTTTRRRRUUUUEEEE if the collection is empty, otherwise returns FFFFAAAALLLLSSSSEEEE. virtual RWBoolean iiiissssEEEEqqqquuuuaaaallll(const RWCollectable* a) const; Inherited from class RRRRWWWWCCCCoooolllllllleeeeccccttttaaaabbbblllleeee. virtual size_t ooooccccccccuuuurrrrrrrreeeennnncccceeeessssOOOOffff(const RWCollectable* t) const = 0; Returns the number of items in the collection which are "matches" tttt. See function ffffiiiinnnndddd(((()))) for a definition of matches. virtual void rrrreeeessssttttoooorrrreeeeGGGGuuuuttttssss(RWFile&); Redefined to repeatedly call the global operator RWFile& operator>>(RWFile&, RWCollectable*&); followed by iiiinnnnsssseeeerrrrtttt((((RRRRWWWWCCCCoooolllllllleeeeccccttttaaaabbbblllleeee****)))) for each item in the collection. virtual void rrrreeeessssttttoooorrrreeeeGGGGuuuuttttssss(RWvistream&); Redefined to repeatedly call the global operator RWvistream& operator>>(RWvistream&, RWCollectable*&); followed by iiiinnnnsssseeeerrrrtttt((((RRRRWWWWCCCCoooolllllllleeeeccccttttaaaabbbblllleeee****)))) for each item in the collection. PPPPaaaaggggeeee 4444 RRRRWWWWCCCCoooolllllllleeeeccccttttiiiioooonnnn((((3333CCCC++++++++)))) RRRRWWWWCCCCoooolllllllleeeeccccttttiiiioooonnnn((((3333CCCC++++++++)))) RWCollectable* rrrreeeemmmmoooovvvveeee(const RWCollectable* target) = 0; Removes and returns a pointer to the first item in the collection which "matches" the object pointed to by ttttaaaarrrrggggeeeetttt. Returns nnnniiiillll if no object was found. Does not delete the object. virtual void rrrreeeemmmmoooovvvveeeeAAAAnnnnddddDDDDeeeessssttttrrrrooooyyyy(const RWCollectable* target); Removes aaaannnndddd ddddeeeelllleeeetttteeeessss the first item in the collection which "matches" the object pointed to by ttttaaaarrrrggggeeeetttt. RWCollection* sssseeeelllleeeecccctttt(RWtestCollectable tst, void* x) const; Evaluates the function pointed to by ttttsssstttt for each item in the collection. It inserts those items for which the function returns TTTTRRRRUUUUEEEE into a new collection allocated off the heap of the same type as self and returns a pointer to this new collection. Because the new collection is allocated ooooffffffff tttthhhheeee hhhheeeeaaaapppp, you are responsible for deleting it when done. This is not a virtual function. virtual void ssssaaaavvvveeeeGGGGuuuuttttssss(RWFile&); Redefined to call the global operator RWFile& operator<<(RWFile&, const RWCollectable&); for each object in the collection. virtual void ssssaaaavvvveeeeGGGGuuuuttttssss(RWvostream&); Redefined to call the global operator RWvostream& operator<<(RWvostream&, const RWCollectable&); PPPPaaaaggggeeee 5555 RRRRWWWWCCCCoooolllllllleeeeccccttttiiiioooonnnn((((3333CCCC++++++++)))) RRRRWWWWCCCCoooolllllllleeeeccccttttiiiioooonnnn((((3333CCCC++++++++)))) for each object in the collection. PPPPaaaaggggeeee 6666